Skip to main content

arr[]

arr[index]

Retrieve the element at position index in the array arr. The first element is arr[0].

Input:
index : integer
Position of desired element to retrieve in array.
Returns:
element - data in the specified index of the array
Return Type:
integer, float, string, list, etc.

weight_ser = pets.get('Weight')
weight_ser
  • dog_00140
  • cat_00115
  • cat_00220
  • dog_00280
  • dog_00325
  • ham_0011
  • ham_0020.25
weight_arr = np.array(weight_ser)
weight_arr

array([40. , 15. , 20. , 80. , 25. , 1. , 0.25])

age_ser = pets.get('Age')
age_ser
  • 05
  • 10.2
  • 29
  • 32
  • 40.5
  • 53
  • 60.2
  • 70
age_arr = np.array(pets.get('Age'))
age_arr

array([5. , 0.2, 9. , 2. , 0.5, 3. , 0.2, 0. ])